//
//  YuYueDetailHeaderView.m
//  FD
//
//  Created by xiaofang wang on 2019/2/12.
//  Copyright © 2019年 ZhiYuan Network. All rights reserved.
//

#import "YuYueDetailHeaderView.h"
//50(上) + 70(下) + 10(间距)
@interface YuYueDetailHeaderView()
/**上 40 */
@property (nonatomic, strong) UIView *upbgView;
/**预约门店lb*/
@property (nonatomic, strong) UILabel *yuyuemenDianLb;

/**下 80*/
@property (nonatomic, strong) UIView *downbgView;
/**icon地址图标*/
@property (nonatomic, strong) UIImageView *iconIV;
/**店铺名字地址lb*/
@property (nonatomic, strong) UILabel *shopAddressLb;
/**姓名联系电话lb*/
@property (nonatomic, strong) UILabel *nameLb;

@end

@implementation YuYueDetailHeaderView

#pragma mark - init

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    self.backgroundColor = kMainLightGrayColor;
    [self addSubview:self.upbgView];
    [self.upbgView addSubview:self.yuyuemenDianLb];
    
    
    [self addSubview:self.downbgView];
    [self.downbgView addSubview:self.iconIV];
    [self.downbgView addSubview:self.shopAddressLb];
    [self.downbgView addSubview:self.nameLb];
}


#pragma mark - layout
- (void)layoutSubviews {
    [super layoutSubviews];
    [self.upbgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self);
        make.height.mas_equalTo(50);
    }];
    [self.yuyuemenDianLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.upbgView.mas_left).offset(15);
        make.top.right.bottom.equalTo(self.upbgView);
    }];
    
    
    //下
    [self.downbgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.upbgView.mas_bottom).offset(1); //1px线
        make.left.right.equalTo(self);
        make.height.mas_equalTo(70);
    }];
    [self.iconIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.downbgView.mas_left).offset(15);
        make.size.mas_equalTo(CGSizeMake(15, 20));
        make.centerY.equalTo(self.downbgView.mas_centerY);
    }];

    [self.shopAddressLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconIV.mas_right).offset(5);
        make.right.equalTo(self.downbgView.mas_right);
        make.top.equalTo(self.downbgView.mas_top).offset(5);
        make.height.mas_equalTo(30);
    }];
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.shopAddressLb.mas_left);
        make.top.equalTo(self.shopAddressLb.mas_bottom);//.offset(5);
        make.right.equalTo(self.downbgView.mas_right);
        make.height.mas_greaterThanOrEqualTo(20);
    }];
}



#pragma mark - 接口
- (void)updateYuYueDetailHeaderViewWithShopAddress:(NSString *)shopAddress personMsg:(NSString *)personMsg {
    self.shopAddressLb.text = shopAddress;
    self.nameLb.text = personMsg;
}


#pragma mark - getter
- (UIView *)upbgView {
    if (!_upbgView) {
        _upbgView = [[UIView alloc] init];
        _upbgView.backgroundColor = [UIColor whiteColor]; //白色
    }
    return _upbgView;
}
- (UILabel *)yuyuemenDianLb {
    if (!_yuyuemenDianLb) {
        _yuyuemenDianLb = [UILabel new];
        _yuyuemenDianLb.text = NSLocalizedString(Order_ReverseShop, @"预约门店");
        _yuyuemenDianLb.font = [UIFont systemFontOfSize:15.0];
    }
    return _yuyuemenDianLb;
}

- (UIView *)downbgView {
    if (!_downbgView) {
        _downbgView = [[UIView alloc] init];
        _downbgView.backgroundColor = [UIColor whiteColor];
    }
    return _downbgView;
}

- (UIImageView *)iconIV {
    if (!_iconIV) {
        _iconIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"address"]];
    }
    return _iconIV;
}
- (UILabel *)shopAddressLb {
    if (!_shopAddressLb) {
        _shopAddressLb = [[UILabel alloc] init];
        _shopAddressLb.font = [UIFont systemFontOfSize:16.0];
//        _shopAddressLb.textColor = kLightGrayTextColor;
//        _shopAddressLb.text = @"Edenhall,model Farm Rd,Cork,Ireland";
    }
    return _shopAddressLb;
}
- (UILabel *)nameLb {
    if (!_nameLb) {
        _nameLb = [[UILabel alloc] init];
//        _nameLb.textColor = kLightGrayTextColor;
//        _nameLb.text = @"xx 先生 1524000000";
        _nameLb.font = [UIFont systemFontOfSize:14.0];
    }
    return _nameLb;
}

@end
